import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class App {
    public static void main(String[] args) throws Exception {
        Employee employee1=new Employee("张三", 10, new MyDate(2011, 1, 1));
        Employee employee2=new Employee("李四", 20, new MyDate(2001, 1, 1));
        Employee employee3=new Employee("王五", 31, new MyDate(1990, 1, 1));
        Set<Employee> Employees=new TreeSet<Employee>();
        Employees.add(employee1);
        Employees.add(employee2);
        Employees.add(employee3);
        Iterator<Employee> iterator=Employees.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }
        set<Employee> Employees2=new TreeSet<Employee>(new Comparator<Employee>(){
            @Override
            public int compare(Employee o1, Employee o2) {
                if(new Date(o1.getBirDate().getYear(), o1.getBirDate().getMonth(), o1.getBirDate().getDay()).getTime()-new Date(o2.getBirDate().getYear(), o2.getBirDate().getMonth(), o2.getBirDate().getDay()).getTime()>0)
                    return 1;
                else
                    return -1;
            }
        });
        Employees2.add(employee1);
        Employees2.add(employee2);
        Employees2.add(employee3);
        for(Employee e:Employees2){
            System.out.println(e);
        }
    }
}
